﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SqlMiM.ReportingServices;
using SqlMiM.ReportingServices.Core;
using SqlMiM.ReportingServices.SqlRs;
using SqlMiM.Common.ViewModel;
using MvvmFoundation.Wpf;


namespace SqlMiM.ReportingServices.ReportExportPlugin
{
    public class ResultWarningViewModel : ObservableObject
    {

        public ResultWarningViewModel()
        {
        }

        public ResultWarningViewModel(ResultWarning warning, ItemTypeEnum itemType)
        {
            this.Warning = warning;
            this.Type = warning.Type;
            this.Message = warning.Message;
            this.CatalogItemType = itemType;

        }

        private ItemTypeEnum catalogItemType;

        public ItemTypeEnum CatalogItemType
        {
            get { return catalogItemType; }
            set
            {
                catalogItemType = value;
                this.RaisePropertyChanged("CatalogItemType");
                this.setIconCatalog();
            }
        }


        private ResultWarning warning;

        public ResultWarning Warning
        {
            get { return warning; }
            set
            {
                warning = value;
                this.RaisePropertyChanged("Warning");
            }
        }

        private ResultWarningType type;

        public ResultWarningType Type
        {
            get { return type; }
            set
            {
                type = value;
                this.RaisePropertyChanged("Type");
                this.setIconResult();
            }
        }

        private void setIconResult()
        {
            switch (this.type)
            {
                case ResultWarningType.Completed:
                    this.IconResult = "/Images/accept.png";
                    break;
                case ResultWarningType.Exception:
                case ResultWarningType.IOException:
                case ResultWarningType.SoapException:
                case ResultWarningType.WebException:
                    this.IconResult = "/Images/cancel.png";
                    break;
                case ResultWarningType.NoDataFound:
                case ResultWarningType.ItemAlreadyExists:
                case ResultWarningType.DataSourcePasswordMustBeSupplied:
                    this.IconResult = "/Images/error.png";
                    break;
                default:
                    this.IconResult = "/Images/cancel.png";
                    break;

            }
        }

        private void setIconCatalog()
        {
            switch (this.CatalogItemType)
            {
                case ItemTypeEnum.DataSource: 
                    this.IconCatalog = "/Images/database_gear.png";
                    break;
                case ItemTypeEnum.Folder:
                    this.IconCatalog = "/Images/folder.png";
                    break;
                case ItemTypeEnum.Report:
                    this.IconCatalog = "/Images/report.png";
                    break;
                case ItemTypeEnum.LinkedReport:
                    this.IconCatalog = "/Images/report_link.png";
                    break;
                case ItemTypeEnum.Model:
                    this.IconCatalog = "/Images/chart_organisation.png";
                    break;
                case ItemTypeEnum.Resource:
                    this.IconCatalog = "/Images/cog.png";
                    break;
                case ItemTypeEnum.Unknown:
                    this.IconCatalog = "/Images/error.png";
                    break;
                default:
                    this.IconCatalog = "/Images/error.png";
                    break;

            }
        }


        private string message;

        public string Message
        {
            get { return message; }
            set
            {
                message = value;
                this.RaisePropertyChanged("Message");
            }
        }

        public string iconCatalog;
        public String IconCatalog
        {
            get
            {
                return iconCatalog;
            }
            set
            {
                iconCatalog = value;
                this.RaisePropertyChanged("IconCatalog");
            }
        }

        public string iconResult;
        public String IconResult
        {
            get
            {
                return iconResult;
            }
            set
            {
                iconResult = value;
                this.RaisePropertyChanged("IconResult");
            }
        }


    }
}
